# Maintainer: Sven-Hendrik Haase <svenstaro@archlinux.org>
# Contributor: Vlad M. <vlad@archlinux.net>

pkgname=watchexec
pkgver=1.23.0
pkgrel=1
pkgdesc="Executes commands in response to file modifications"
url='https://github.com/watchexec/watchexec'
depends=('gcc-libs' 'zlib')
makedepends=('cargo')
arch=('loong64' 'x86_64')
license=('Apache')
source=("$pkgname-$pkgver.tar.gz::https://github.com/watchexec/watchexec/archive/refs/tags/v${pkgver}.tar.gz")
options=('!lto')
sha256sums=('2a321962669979feef44ea7a6220819d5c916ca939eba41b033ea346a44caa90')

build() {
  cd "watchexec-$pkgver"
  cargo build --release --locked
}

check() {
  cd "watchexec-$pkgver"
  cargo test --locked
}

package() {
  cd "watchexec-$pkgver"
  install -Dm644 "doc/watchexec.1" "$pkgdir/usr/share/man/man1/watchexec.1"
  gzip -9 "$pkgdir/usr/share/man/man1/watchexec.1"
  install -Dm644 "completions/zsh" "$pkgdir/usr/share/zsh/site-functions/_watchexec"
  install -Dm755 "target/release/$pkgname" "$pkgdir/usr/bin/$pkgname"
  install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}
